package com.gues.controller;

import com.gues.result.Result;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;

@RestController
public class TestController {

    @RequiresPermissions({"save"}) //没有的话 AuthorizationException
    @PostMapping("/save")
    public Result save() {
        System.out.println("save");
        return new Result(200, "当前用户有save的权力");
    }//f603cd4348b8f1d41226e3f555d392bd

    @RequiresPermissions({"delete"}) //没有的话 AuthorizationException
    @DeleteMapping("/delete")
    public Result delete() {
        System.out.println("delete");
        return new Result(200, "当前用户有delete的权力");
    }

    @RequiresPermissions({"update"}) //没有的话 AuthorizationException
    @PutMapping("/update")
    public Result update() {
        System.out.println("update");
        return new Result(200, "当前用户有update的权力");
    }

    @RequiresPermissions({"select"}) //没有的话 AuthorizationException
    @GetMapping("/select")
    public Result select() {
        System.out.println("select");
        return new Result(200, "当前用户有select的权力");
    }

    @RequiresRoles({"vip"}) //没有的话 AuthorizationException
    @GetMapping("/vip")
    public Result vip() {
        System.out.println("vip");
        return new Result(200, "当前用户有VIP角色");
    }
    @RequiresRoles({"svip"}) //没有的话 AuthorizationException
    @GetMapping("/svip")
    public Result svip() {
        System.out.println("svip");
        return new Result(200, "当前用户有SVIP角色");
    }
    @RequiresRoles({"p"}) //没有的话 AuthorizationException
    @GetMapping("/p")
    public Result p() {
        System.out.println("p");
        return new Result(200, "当前用户有P角色");
    }
}
